package com.cf.controller;

import com.cf.entity.Item;
import com.cf.entity.Result;
import com.cf.service.UserItemService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
public class UserItemController {
    @Autowired
    private UserItemService userItemService;

    @RequestMapping("/selectItemByUserId")
    public Object selectItemByUserId(@RequestParam(defaultValue = "1") int pagenum, int pagesize, long userid){
        PageInfo<Item> pageInfo = userItemService.selectItemByUserId(pagenum, pagesize, userid);
        if (pageInfo.getList().size()!=0){
            return new Result(200,"查询成功",pageInfo);
        }else {
            return new Result(400,"查询失败",null);
        }
    }
}
